

<template>
  <div class="rightCZ">
    <div class="buts">

<el-button size="mini" type="primary" @click="editUserInfo()">患者信息</el-button>
      <el-button size="mini" type="primary" @click="selectHistoryBingLi()">历史病历</el-button>
       <el-button size="mini" type="primary" @click="addzhenduan('zd_use_medical_record_tpl_id')">诊断证明</el-button>
       <el-dropdown @command="addzhenduan">
  <el-button type="primary">
    检查单<i class="el-icon-arrow-down el-icon--right"></i>
  </el-button>
  <el-dropdown-menu slot="dropdown">
    <el-dropdown-item  command="jcjy_medical_record_tpl_id" >检查检验申请单</el-dropdown-item>
    <el-dropdown-item command='bc_medical_record_tpl_id' >B超申请单</el-dropdown-item>
    <el-dropdown-item command='jc_medical_record_tpl_id' >检查申请单</el-dropdown-item>

  </el-dropdown-menu>
</el-dropdown>
      <!-- <el-button size="mini" type="success">打印</el-button> -->

      <el-button size="mini" type="primary" @click="examine()">查看</el-button>

       <el-button size="mini" type="success" @click="save(1)" >暂存</el-button>
      <el-button size="mini" type="success" @click="save(2)" >保存</el-button>
    </div>
    <div class="userinfo">
      <div>
        姓名：<span>{{ thatF.PatientInfoData.member_info.name }}</span>
      </div>
      <div>
        挂号初复诊：<span>{{
          thatF.PatientInfoData.look_type == 1 ? "初诊" : "复诊"
        }}</span>
      </div>
      <div>
        门诊号：<span>{{ thatF.PatientInfoData.patient_no }}</span>
      </div>
      <div>
        残联金额：<span>{{ thatF.PatientInfoData.member_info.disabled_info?thatF.PatientInfoData.member_info.disabled_info.clinic_balance:0 }}</span>
      </div>
    </div>
    <div>
      <el-tabs v-model="tabIndex" type="card" @tab-click="handleClick">
        <!-- 病例 -->
        <el-tab-pane label="病历" name="one">
          <bingLi ref="bingli"   :thatF="this"></bingLi>
          <!-- <el-button @click="openDeve">病例列表</el-button>
             <el-button @click="openDeve">新增病历</el-button> -->
        </el-tab-pane>


        <!-- 处方 -->

        <el-tab-pane label="药品处方" name="three">
          <div class="selects" style="display:flex;width: 100%;">
            <div class="selectTables" style="width: 20%">
              <el-popover  placement="right" width="500px" trigger="focus">
                <el-input
                  placeholder="选择药品"
                  slot="reference"
                  v-model="selectParams.keyword"
                  @input="getDrugItem()"
                >
                  <i slot="suffix" class="el-input__icon el-icon-search"></i>
                </el-input>

                <el-table
                  v-loading="thatF.threeSelectLoading"
                  height="300"
                  @current-change="xuanzeDataThree"
                  highlight-current-row
                  :data="selectData.selectData2"
                  style="width: 100%"
                >
                  <el-table-column label="序号" width="50"> </el-table-column>
                  <el-table-column label="药品名称" prop="name" width="150">
                  </el-table-column>
                  <el-table-column label="价格" prop="price" width="50">
                  </el-table-column>
                  <el-table-column
                    label="规格"
                    prop="specification"
                    width="300"
                  >
                  </el-table-column>
                </el-table>
                <el-pagination
                  :current-page="selectParams.page"
                  :page-size="selectParams.limit"
                  @current-change="handlePagination"
                  :total="selectParams.pageCount"
                  layout="prev, pager, next"
                >
                </el-pagination>
              </el-popover>
            </div>
            <div style="padding-left:10px;width: 80%;"> <el-input v-model="cf_remark" placeholder="处方备注"></el-input></div>
          </div>

          <div>
            <el-table :data="tableData2" style="width: 100%">
              <template v-for="(item, index) in tableTitle">
                <el-table-column
               
                  v-if="item.prop == 'used_frqu'"
                  :prop="item.prop"
                   :width="item.width"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-select
                        v-model="scope.row.used_frqu"
                        placeholder="频次"
                      >
                        <el-option
                          v-for="item in thatF.pinci"
                          :key="item.name"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </span>
                  </template>
                </el-table-column>


                <el-table-column
                  v-else-if="item.prop == 'dose'"
                  :width="item.width"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-input
                        v-model="scope.row.dose"
                        placeholder="单次剂量"
                      ></el-input>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'dose_unit'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-select v-model="scope.row.dose_unit" placeholder="剂量单位">
                        <el-option
                          v-for="item in thatF.dose_unit"
                          :key="item.name"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'usage'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-select v-model="scope.row.usage" placeholder="用法">
                        <el-option
                          v-for="item in thatF.geiyao"
                          :key="item.name"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  v-else-if="item.prop == 'count'"
                  :width="item.width"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-input
                      @input="watchCount"
                        v-model="scope.row.count"
                        placeholder="数量"

                      ></el-input>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'is_skin_test'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-checkbox
                        v-model="scope.row.is_skin_test"
                      ></el-checkbox>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'trans_speed'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <span>
                        <el-select
                          v-model="scope.row.trans_speed"
                          placeholder="滴速"
                        >
                          <el-option
                            v-for="item in thatF.disu"
                            :key="item.name"
                            :label="item.name"
                            :value="item.id"
                          >
                          </el-option>
                        </el-select>
                      </span>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'usage_extra'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-select
                        v-model="scope.row.usage_extra"
                        placeholder="西药脚注"
                      >
                        <el-option
                          v-for="item in thatF.xiyaojiaozhu"
                          :key="item.name"
                          :label="item.name"
                          :value="item.id"
                        >
                        </el-option>
                      </el-select>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'remark'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <span>
                        <el-input
                          v-model="scope.row.remark"
                          placeholder="备注"
                        ></el-input>
                      </span>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                </el-table-column>
              </template>

              <el-table-column fixed="right" label="操作" width="120">
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="deleteRow(scope.$index, tableData2)"
                    type="text"
                    size="small"
                  >
                    移除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
  
            <div  class="countPrice">总价：{{countPrice}}</div>
          </div>
        </el-tab-pane>
        <el-tab-pane label="诊疗项目" name="four">
          <div class="selects">
            <div class="selectTables">
              <el-popover  placement="right" width="500px" trigger="focus">
                <el-input
                  placeholder="选择项目名称"
                  slot="reference"
                  v-model="selectParams.keyword"
                  @input="getDrugItem()"
                >
                  <i slot="suffix" class="el-input__icon el-icon-search"></i>
                </el-input>
                <el-tabs v-model="activeName" type="card" @tab-click="projectClick">
                <el-tab-pane label="项目" name="first">
                <el-table
                  v-loading="thatF.threeSelectLoading"
                  @current-change="xuanzeDataFour"
                  highlight-current-row
                  :data="selectData.selectData3"
                  style="width: 100%"
                  height="300"
                >
                  <el-table-column label="序号" prop="id" width="50">
                  </el-table-column>
                  <el-table-column label="项目名称" prop="name" width="200">
                  </el-table-column>

                  <el-table-column label="价格" prop="price" width="50">
                  </el-table-column>
                </el-table>
                <el-pagination
                  :current-page="selectParams.page"
                  :page-size="selectParams.limit"
                  @current-change="handlePagination"
                  :total="selectParams.pageCount"
                  layout="prev, pager, next"
                >
                </el-pagination>
                  </el-tab-pane>
             <el-tab-pane label="组合项目" name="second">
               <el-table
              v-loading="combinationSelectParams.Logding"
            
              highlight-current-row
              :data="combinationSelectParams.data"
              style="width: 100%"
              height="300"
            >
              <el-table-column label="序号" prop="id" width="50">
              </el-table-column>
              <el-table-column label="标题" prop="title" width="200">
              </el-table-column>

              <el-table-column label="备注" prop="remark" width="50">
              </el-table-column>
               <el-table-column
                
                label="操作"
                width="100">
                <template slot-scope="scope">
                  <!--  @click="handleClick(scope.row)" -->
                  <el-button  @click="combinationClick(scope.row)" type="text" size="small">添加</el-button>
                </template>
              </el-table-column>
            </el-table>
             </el-tab-pane>
              </el-tabs>
              </el-popover>
            </div>
          </div>
          <div>
            <el-table :data="tableData3" style="width: 100%">
              <template v-for="(item, index) in tableTitle">
                <el-table-column
                  :width="item.width"
                  v-if="item.prop == 'position'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-input
                        v-model="scope.row.position"
                        placeholder="部位"
                      ></el-input>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'once'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-input
                        v-model="scope.row.once"
                        type="number"
                        placeholder="次数"
                        min="1"
                      ></el-input>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'is_fast'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-checkbox v-model="scope.row.is_fast"></el-checkbox>
                    </span>
                  </template>
                </el-table-column>

                <el-table-column
                  :width="item.width"
                  v-else-if="item.prop == 'remark'"
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                  <template slot-scope="scope">
                    <span>
                      <el-input
                        v-model="scope.row.remark"
                        type="text"
                        placeholder="备注"
                      ></el-input>
                    </span>
                  </template>
                </el-table-column>
                <el-table-column
                  :width="item.width"
                  v-else
                  :prop="item.prop"
                  :label="item.label"
                  :key="index"
                >
                </el-table-column>
              </template>
              <el-table-column fixed="right" label="操作" width="120">
                <template slot-scope="scope">
                  <el-button
                    @click.native.prevent="deleteRow(scope.$index, tableData3)"
                    type="text"
                    size="small"
                  >
                    移除
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <el-dialog
      title="查看"
      :visible.sync="dialogVisible"
      width="100%"
      top="0"
      :before-close="handleClose"
    >
      <span>
        <iframeDemo :url="url" ref="iframeDemo" height="700px" />
      </span>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="dialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>

<el-dialog title="历史病历" class="bingli_el-dialog__body" v-if="historyBingLi.show" :fullscreen='true' :modal-append-to-body="false" :visible.sync="historyBingLi.show" :destroy-on-close="true">

                   <historyBingLidialog :thatF="this"></historyBingLidialog>
                     <!-- <bllist  :thatF="this" ref="bllist"></bllist> -->
            </el-dialog>
          <el-dialog title="患者信息" class="patientInfo" v-if="patient.show" :fullscreen='true' :modal-append-to-body="false" :visible.sync="patient.show" :destroy-on-close="true">

                   <patientInfo :listType="3" @handleClick="handleClick" :thatF="this" :patient="patient.data"></patientInfo>
                     <!-- <bllist  :thatF="this" ref="bllist"></bllist> -->
            </el-dialog>
    <iframeDemo
      :url="url"
      ref="iframeDemo"
      height="500px"
      style="display: none"
    />

  </div>
</template>
<script>
import bingLi from "./bl/bl.vue";

import { iframeUrl,http2   } from "@/utils/server.js";
import iframeDemo from "@/components/iframeDemo/index.vue";
import historyBingLidialog from "./bl/historyBingLidialog.vue";
// import patientInfo from "./patient/info.vue";
import { Loading } from 'element-ui';
import patientInfo from "@/components/patientInfo/index.vue";
import { mapState,mapMutations  } from "vuex";
let that;
export default {
  props: ["selectParams", "selectData", "thatF"],
  data() {
    return {
      activeName:'first',
       combinationSelectParams:{
        data:[],
        Logding:false,
      },
      countPrice:0, //总价
      patient:{
        show:false,
        data:{},
      },
      fullscreenLoading:false,
      url: `${iframeUrl}/#/info?type=2`,
      dialogVisible: false,
      tabIndex: "one",
      params: {},
      search: "",
      two_select_data: [
        {
          id: "1",
          card: "123213",
          name: "小胡1",
          type: "hsd",
        },
        {
          id: "2",
          card: "sadasd",
          name: "小黑2",
          type: "fdgdfg",
        },
      ],
      tableTitle: [],
      tableData2: [],
      tableData3: [],
      cf_remark:'',
     historyBingLi:{
       show:false,
     },
    };
  },
  mounted() {
    that = this;
     this.tableTitle = [];

  },
   computed: {
    ...mapState({
       tableData1: (state) => state.doctorWorkStation.tableData1,



    }),
  },
 
  methods: {

      ...mapMutations([
				'doctorWorkStation/set_memberInfo',
        	'doctorWorkStation/set_tableData1',
			]),
        addzhenduan(key2){
        console.log(key2)
        let loading        //定义loading变量
        loading = Loading.service({
          lock: true,
          text: '加载中……',
          background: 'rgba(255,255,255, 0)'
        })
         let d={
         
              patient_no:this.thatF.PatientInfoData.patient_no,
          }
         
            // var http=`${http2}?tepid=72&is_pattern=2&uid=${data.id}&source=4&his_uid=${data.member_info.id}&real_name=${this.real_name}&tep_name="门诊病历"`
        
        // window.open(http,'_blank');

         this['_API'].getClinic_doctorGetMedicalRecordDetail(d).then(res=>{
          //  this.dialogVisible = true
          //  loading.close()
           if(res.code==-1){
              this['_API'].getByKey({key:key2}).then(res2=>{
                 var clinic_use_medical_record_tpl_id=''
                if(res2.code==200){
                  if(key2=='zd_use_medical_record_tpl_id'){
                     clinic_use_medical_record_tpl_id= res2.data.zd_use_medical_record_tpl_id
                  }else if(key2=='jcjy_medical_record_tpl_id'){
                     clinic_use_medical_record_tpl_id= res2.data.jcjy_medical_record_tpl_id

                  }else if(key2=='bc_medical_record_tpl_id'){
                     clinic_use_medical_record_tpl_id= res2.data.bc_medical_record_tpl_id

                  }else if(key2=='jc_medical_record_tpl_id'){
                     clinic_use_medical_record_tpl_id= res2.data.jc_medical_record_tpl_id

                  }
   
                    var http=`${http2}?tepid=${clinic_use_medical_record_tpl_id}&is_pattern=2&source=4&his_uid=&real_name=${this.real_name}&tep_name=诊断证明&patient_no=${d.patient_no}`
        
        window.open(http,'_blank');
     
           loading.close()
                }
            })
           }
           let data = res.data
            this['_API'].getByKey({key:'zd_use_medical_record_tpl_id'}).then(res2=>{
                if(res2.code==200){
                    var clinic_use_medical_record_tpl_id= res2.data.zd_use_medical_record_tpl_id
                    var http=`${http2}?tepid=${clinic_use_medical_record_tpl_id}&is_pattern=2&source=4&his_uid=${data.member_info.id}&real_name=${this.real_name}&tep_name=诊断证明&patient_no=${data.patient_no}`
        
        window.open(http,'_blank');
     
           loading.close()
                }
            })
            .catch(e=>{
              console.log(e)
            })
         })
    },
      watchCount(){
        
        let price=0;
      
        this.tableData2.forEach(v=>{
          if(v.count&&v.price&&v.count!='0'){
         
             let p1=Math.round((v.count*v.price)*1000)/1000;
             price=Math.round((price+p1)*1000)/1000;
            
          }
        })
        this.countPrice=price.toFixed(2);
      },
      editUserInfo(){
      //
        console.log("PatientInfoData",this.thatF.PatientInfoData.member_info.id)
        let d={
          member_id:this.thatF.PatientInfoData.member_info.id,
        }
        this['_API'].getMemberProFile(d).then(res=>{
            console.log("res",res) 
            if(res.code==200){

                 res.data.family = res.data.get_family
                  res.data.nature=!res.data.nature?'':res.data.nature;
                  res.data.card_type=!res.data.card_type?'':res.data.card_type;
                  
                  // res.data.edu_level =       
                

              
                 this.patient.data=res.data;
                 this.patient.show=true;
               
                 console.log("this.patient.data=",this.patient.data)
            }
        })
      },
    selectHistoryBingLi(){
      this.historyBingLi.show=true;
      this['doctorWorkStation/set_memberInfo'](this.thatF.PatientInfoData.member_info)
    },
    examine(){
      let text = ""
      this.tableData1.forEach((item,key)=>{
        if(key == this.tableData1.length-1){
          text += item.name
        }else{
          text += (item.name + '&')
        }
      })
      console.log(text)
      this.dialogVisible = true
      this.url = `${iframeUrl}/#/info?type=1`
      let data = this.$refs.bingli.params
      console.log(data)
      let list = this.thatF.PatientInfoData
      console.log("进入查看病例")
       setTimeout(function(){ 
          that.$nextTick(function(){
          let json = {
            id:10,
            hospitalName:process.env.VUE_APP_HOSPITAL_API,
            main_desc:data.main_desc,
            medical_history:data.medical_history,
            family_history:data.family_history,
            check_result:data.check_result,
            allergy_history:data.allergy_history,
            body_check:data.body_check,
            medical_now:data.medical_now,
            remark:data.remark,
            spirit_check:data.spirit_check,
            treatment:data.treatment,
            with_user:data.with_user,
            name:list.member_info.name,
            member_Id:list.member_info.id,
            gender:list.member_info.gender == 1 ? '男' : list.member_info.gender == 2 ? '女' : '未知',
            birthday:list.member_info.birthday,
            patient_no:list.patient_no,
            dept_name:list.doctor_info.dept_name,
            real_name:list.doctor_info.real_name,
            created_at:list.created_at,
            look_type:list.look_type == 1 ? '初诊' : '复诊',
            with_user_name:"",
            with_user_phone:"",
            text:text,
            treatment:"",
            type:1
          };
          that.$refs.iframeDemo.handleEmit(json);
        });
      }, 100);
    },
    handleClose() {
      this.dialogVisible = false;
    },
    save(type) {
      let d_zd = {
        ...this.$refs.bingli.params,
        attack_date:this.$refs.bingli.attack_date,
        is_infect:this.$refs.bingli.is_infect,
        save_status:type,
      }; //保存诊断信息
  
      let d_cf_zl = {}; //处方和诊疗信息


      d_zd.patient_no = this.thatF.PatientInfoData.patient_no;
      d_cf_zl.patient_no = this.thatF.PatientInfoData.patient_no;
     d_cf_zl.remark=this.cf_remark;
      if (this.tableData1.length <= 0) {
        return this.$message({
          message: "请选择诊断类型",
          type: "warning",
        });
      }
      d_zd.diagnosis = [];
      this.tableData1.forEach((res) => {
        d_zd.diagnosis.push({
          id: res.id,
          name: res.name,
          code: res.code,
        });
      });

      console.log(d_zd);
      d_cf_zl.drug_item = [];
      d_cf_zl.service_item = [];

      //添加处方信息

        if (this.tableData2.length >0) {
              this.tableData2.forEach(res=>{
           d_cf_zl.drug_item.push({
             drug_id:res.id,
             unm_unit:res.base_unit,
             num:res.count,
             dose:res.dose,
             dose_unit:res.dose_unit,
             usage:res.usage,
             each_dos:res.used_frqu,
             base_unit:res.base_unit,
             trans_speed:res.trans_speed,
             usage_extra:res.usage_extra,
             is_skin_test:res.is_skin_test?1:0,
             remark:res.remark,

          });
        });
      }

      if (this.tableData3.length > 0) {
        this.tableData3.forEach((res) => {
          d_cf_zl.service_item.push({
            service_id: res.id,
          //  position: res.position,
            once: 1,

            is_fast: res.is_fast ? 1 : 0,
            remark: res.remark,

          });
        });
      }
       this.fullscreenLoading = true;

        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
      this["_API"].getClinic_doctorSaveMedicalRecord(d_zd).then((res) => {

        if (res.code == 200) {
          this["_API"].getClinic_doctorSaveRecipe(d_cf_zl).then((res) => {
             loading.close();
         
            if (res.code == 200) {

              // this['doctorWorkStation/set_tableData1']([])


            
              if(type==2){
                  this.$message({
                    message: "保存成功，已诊患者里面可以修改处方以及诊疗项目",
                    type: "success",
                  });
                  this.thatF.tabName = "third";
                  this.thatF.handleClick();
              }else if(type==1){
                 this.$message({
                    message: "暂存成功",
                    type: "success",
                  });
              }
            
            }
          });
        }
      });
    },
    getDrugItem() {
      this.thatF.threeSelectLoading = true;
      this.thatF.selectParams.page = 1;
      if (this.tabIndex == "two") {
        this.thatF.getDiseaseDict();
      } else if (this.tabIndex == "three") {
        this.thatF.getDrugItem();
      } else if (this.tabIndex == "four") {
        this.thatF.getServiceItem();
      }
    },
    handlePagination(e) {
      this.thatF.threeSelectLoading = true;
      this.selectParams.page = e;

      if (this.tabIndex == "three") {
        this.$emit("getDrugItem");
      } else if (this.tabIndex == "four") {
        this.thatF.getServiceItem();
      }
    },
    deleteRow(index, rows) {
      rows.splice(index, 1);
    },

    xuanzeDataThree(item) {
      if (this.tableData2.findIndex((res) => res.id == item.id) === -1) {
        
         item.used_frqu= item.used_frqu? item.used_frqu:'';

          if(item.used_frqu){
           this.thatF.pinci.forEach(pc1=>{
                if(pc1.name==item.used_frqu){
                  item.used_frqu=pc1.id;
                }
              })
         }

         if(item.usage){
           this.thatF.geiyao.forEach(gy1=>{
                if(gy1.name==item.usage){
                  item.usage=gy1.id;
                }
              })
         }
        this.tableData2 = this.tableData2.concat(item);
      }
      console.log("tableData2",this.tableData2)
    },
    xuanzeDataFour(item) {
      item.once = 1;
      // console.log("item",)
      if (this.tableData3.findIndex((res) => res.id == item.id) === -1) {
        this.tableData3 = this.tableData3.concat(item);

        //  this.tableData3.
      }
    },
    handleClick(e) {
      this.selectParams.keyword = "";
      if (this.tabIndex == "one") {

        if(this.tableData2.length>0){
        let atreatment=  this.tableData2.map((v,index)=>{
          v.count=v.count?v.count:0;
            let str=index!==0?'\n':''

            let pinci='';
            let yongfa='';
            //v.used_frqu
            //v.usage
            if(v.used_frqu){
              this.thatF.pinci.forEach(pc1=>{
                if(pc1.id==v.used_frqu){
                  pinci=pc1.name;
                }
              })
            }
            if(v.usage){
               this.thatF.geiyao.forEach(gy1=>{
                if(gy1.id==v.usage){
                  yongfa=gy1.name;
                }
              })
            }
         
            return str+(index+1)+': '+v.name+' '+v.specification+' , 每次'+v.dose+v.dose_unit+'  '+pinci+'  '+yongfa;
          })

         
         this.$refs.bingli.params.treatment=atreatment.toString()
         
        }
        this.tableTitle = this.$baseBai["workstation"]["right_two_table_title"];

        this.$emit("getDiseaseDict");
      } else
       if (this.tabIndex == "three") {
        this.tableTitle =
          this.$baseBai["workstation"]["right_three_table_title"];

        this.$emit("getDrugItem");
      } else if (this.tabIndex == "four") {
        this.tableTitle =
          this.$baseBai["workstation"]["right_four_table_title"];

        this.$emit("getServiceItem");
      }
    },
    openDeve() {
      return this.$message({
        message: "此模块开发中.....",
        type: "warning",
      });
    },
     projectClick(tab){
      console.log(tab.paneName)
      if(tab.paneName=='second'){
        this.getServiceGroup()
      }
    },
    getServiceGroup(){
       let d = {
 
      };
       this.combinationSelectParams.Logding = true;
      this["_API"].getservice_feegetServiceGroup(d).then((res) => {
        console.log("res",res)
        if(res.code==200){
         this.combinationSelectParams.data=res.data
        }
        this.combinationSelectParams.Logding = false;
      });
    },
      combinationClick(e){
      
      e.extra_json.forEach(v => {
          
         
          if(this.tableData3.findIndex(v2=>v2.id==v.id)===-1){
            v.once=1;
            this.tableData3 = this.tableData3.concat([v]);
          }
      });
      

 
      // if (this.tableData3.findIndex((res) => res.id == item.id) === -1) {
      //   this.tableData3 = this.tableData3.concat(item);

      //   //  this.tableData3.
      // }
       // 
   
      
    },
  },
  components: {
    bingLi,
    iframeDemo,
    historyBingLidialog,
    patientInfo,

  },
};
</script>
<style lang='scss' scoped>
.userinfo {
  display: flex;
  align-items: center;
  border: 1px solid #e7e7e7;
  padding-left: 30px;
  line-height: 29px;
  // border-radius: 20px;
  margin-bottom: 5px;
  > div {
    flex: 1;
  }
}
.buts {
  display: flex;
  // justify-content: flex-end;
  margin-bottom: 5px;
}

.selects {
  position: relative;
  // /deep/ .el-input{
  //   width: 300px;
  // }

  .selectTables {
    width: 300px;
  }
}
/deep/ .el-input-number {
  width: 90px;
}
/deep/ .el-input-number .el-input__inner {
  padding-left: 0;
  padding-right: 0;
  text-align: center;
}

// /deep/ .el-dialog {
//   height: 100vh;
//   display: flex;
//   flex-direction: column;
//   justify-content: space-between;
// }
// /deep/ .bingli_el-dialog__body{
//   /deep/  .dialog__body{
//           position: absolute;
//         top: 27px;
//     }
// }

  // /deep/ .is-fullscreen{
  //   width: 60%;
  // }

  /deep/ .patientInfo{
     /deep/ .is-fullscreen{
      width: 100% !important;
    }
  }
  .countPrice{
      padding-top: 30px;
    text-align: right;
    color: red;
    font-size: 33px;
  }
</style>
